import React from 'react'
import * as echarts from 'echarts';
import {useRef,useEffect} from "react"
import {pieoption} from "../options/pieoption"
import {useDispatch,useSelector} from "react-redux"
import * as action from "../action"
function PieChart() {
   let dispatch = useDispatch()
   let store = useSelector((state)=>{
        return {
            ...state.appreducer
        }  
   })
   let piechart = useRef(null)
   useEffect(()=>{
        dispatch(action.getlist())
        console.log(store.arr,"arr");
      
   },[])
   useEffect(()=>{
    pieoption.series[0].data = store.arr
    let myChart = echarts.init(piechart.current)
    pieoption && myChart.setOption(pieoption);
   },[store.arr])
  return (
    <div ref={piechart} style={{width:"100%",height:"375px"}}>PieChart</div>
  )
}

export default PieChart